package thread;

/**
 * Creared with IntelliJ IDEA.
 * Description:
 * User:yxd
 * Date:2022-03-26
 * Time:23:15
 */
public class Demo19 {
    private static Object o = new Object();
    public static void main(String[] args) {
        Thread t1 = new Thread(()->{
            //wait()
            synchronized (o){
                System.out.println("wait 前");
                try {
                    o.wait();
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
                System.out.println("wait 后");
            }

        });
        t1.start();
        Thread t2 = new Thread(()->{
            //notify()
            synchronized (o){
                System.out.println("notify 前");
                o.notify();
                System.out.println("notify 后");

            }
        });
        t2.start();
    }
}
